/*
 * Heap_Common.h
 *
 *  Created on: Oct 31, 2009
 *      Author: swapnil
 */
#ifndef HEAP_COMMON_H_
#define HEAP_COMMON_H_

#include <time.h>
#include <malloc.h>
#include "../Page.h"

#define MAX_DES ((PAGE_SIZE-sizeof(dpH))/sizeof(de))
/*
 * Structures used for DP page initialization
 * */
typedef struct dpH{

		int nextDp;
		int numberOfDe;
		int maxEmptySpace;
	}dpH;

	typedef struct de{

		int pageNumber;
		int freeSpace;
	}de;

	typedef struct dp{

		dpH dpHeader;
		de dirElement[MAX_DES];
	}dp;

	/*
	 * Strucutes used for DB Page
	 */

		typedef struct header_t{
				time_t timeStamp; // number of slots in the page
				int freeSpace;

			  }header_t;

		  typedef struct slot_t{
			int offset; // offset of the data in the page
			int length; // length of data from the offset

		  }slot_t;

		  	  typedef struct sysCol{

		  		  char data[PAGE_SIZE];
		  	  }sysCol;

		  	  typedef struct systab{

		  		  char data[PAGE_SIZE];
		  	  } systab;

const static int dpHeaderSize = sizeof(dpH);
const static int deSize = sizeof(de);
const static int dpSize = sizeof(dp);

const static int headerSize = sizeof(header_t);
const static int slotSize = sizeof(slot_t);

#endif /* HEAP_COMMON_H_ */
